package domainspecific.types;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 * A single meter reading. 
 * @author Markus Jung
 */
public class Reading implements Serializable{
	private long date;
	private double energy;
	private double power;
	private int meterId;
	
	/**
	 * Just for creating test data
	 */
	private static long curEnergy = 5; 
	private static long curTime = System.currentTimeMillis() - (System.currentTimeMillis() % (1000 * 60 * 15)); 
	
	public Reading(){
		curEnergy += Math.random() * 2; // KWH
		this.setEnergy(curEnergy);
		this.setPower(Math.random() * 800 + 200); // 200 to 1000 Watt
		curTime+= 1000 * 60 * 15;
		setDate(System.currentTimeMillis()/1000);	
		this.meterId = (int)(UUID.randomUUID().getLeastSignificantBits());
	}
	
	public Reading(int id, Date date, double energy, double power)
	{
		this.meterId = id;
		this.date = date.getTime()/1000;
		this.energy = energy;
		this.power = power;
	}
			
	public void setDate(long date) {
		this.date = date;
	}

	public long getDate() {
		return date;
	}
	
	public void setEnergy(double energy) {
		this.energy = energy;
	}


	public double getEnergy() {
		return energy;
	}


	public void setPower(double power) {
		this.power = power;
	}


	public double getPower() {
		return power;
	}
	
	public void setMeterId(int id)
	{
		this.meterId = id;
	}
	
	public int getMeterId()
	{
		return this.meterId;
	}
}
